﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProDivingAdmin2salmon14
{   
    /// <summary>
    /// The class Judge contains properties and constructors for a Judge-object. 
    /// </summary>
    public class Judge
    {
        public int ID { get; set; }
        public string fullName { get; set; }
        public string nationality { get; set; }
        public float score { get; set; }
        public bool isConnected { get; set; }
        public int order { get; set; }

        /// <summary>
        /// The empty constructor simply sets the "score" property of a judge to 0.0f.
        /// </summary>

        public Judge() 
        {
            this.score = 0.0f;
        }

        /// <summary>
        /// This constructor takes an object of the Judge-class as argument and sets each of constructed judge's properties to the properties of the Judge given in the argument.
        /// </summary>
        /// <param name="judge"></param>

        public Judge(Judge judge) 
        {
            this.ID = judge.ID;
            this.fullName = judge.fullName;
            this.nationality = judge.nationality;
            this.score = judge.score;
            this.isConnected = judge.isConnected;
            this.order = judge.order;
        }

        /// <summary>
        /// This constructor takes arguments for the properties fullName, nationality, id and order and sets them. 
        /// This is constructor is used when reading a list of judges from file.
        /// </summary>
        /// <param name="fullName"></param>
        /// <param name="nationality"></param>
        /// <param name="ID"></param>
        /// <param name="order"></param>

        public Judge(string fullName, string nationality, int ID, int order) 
        {
            this.fullName = fullName;
            this.nationality = nationality;
            this.ID = ID;
            this.order = order;
        }

        /// <summary>
        /// This constructor only takes fullName, nationality and ID as arguments. 
        /// Here we try to set the order property by looking at the prior judge's order number. 
        /// If no other judges exist and the judge we are now initiating is the first, we catch an argument exception and set order to "1".
        /// This constructor is used when adding a judge with the Add/Edit form. 
        /// </summary>
        /// <param name="fullName"></param>
        /// <param name="nationality"></param>
        /// <param name="ID"></param>

        public Judge(string fullName, string nationality, int ID)
        {
            this.fullName = fullName;
            this.nationality = nationality;
            this.ID = ID;
            try
            {
                this.order = Contest.judgeList[Contest.judgeList.Count - 1].order + 1;
            }
            catch (ArgumentOutOfRangeException)
            {
                this.order = 1;
            }
        }
    }
}
